import mallApi from "@/api/declaration/mall/mallApi"
import httpRequest from "@/config/axios/httpRequest"
import { SpuModel } from "@/models/mall/PropertyModel"








// 获得 Spu 列表
export const getSpuPage = (params: PageParam) => {
  return httpRequest.get(mallApi.GetSpuPage, { params })
}

// 获得 Spu 列表 tabsCount
export const getTabsCount = () => {
  return httpRequest.get(mallApi.GetTabsCount)
}

// 创建商品 Spu
export const createSpu = (data: SpuModel) => {
  return httpRequest.post(mallApi.CreateSpu, data)
}

// 更新商品 Spu
export const updateSpu = (data: SpuModel) => {
  return httpRequest.put(mallApi.UpdateSpu, data)
}

// 更新商品 Spu status
export const updateStatus = (data: { id: number; status: number }) => {
  return httpRequest.put(mallApi.UpdateStatus, data)
}

// 获得商品 Spu
export const getSpu = (id: number) => {
  return httpRequest.get(mallApi.GetSpu, { params: { id } })
}

// 获得商品 Spu 详情列表
export const getSpuDetailList = (ids: number[]) => {
  return httpRequest.get(mallApi.GetSpuDetailList, { params: { ids } })
}

// 删除商品 Spu
export const deleteSpu = (id: number) => {
  return httpRequest.delete(mallApi.DeleteSpu, { params: { id } })
}

// 导出商品 Spu Excel
export const exportSpu = async (params) => {
  return await httpRequest.get(mallApi.ExportSpu, { params })
}

// 获得商品 SPU 精简列表
export const getSpuSimpleList = async () => {
  return await httpRequest.get(mallApi.GetSpuSimpleList)
}
